using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using IGlobalist.Cms.Common;
using IGlobalist.Cms.Model;
using IGlobalist.Cms.Bll;

namespace IGlobalist.Cms.Admin.Control
{
    public partial class ProductViewDetail : AdminBaseUserControl
    {
        public event EventHandler EventReturnProductListSummary;
        public event EventHandler EventImageEdit;
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        public void DoBind(object sender, EventArgs e)
        {
            ProductListSummary productSummaryList = (ProductListSummary)sender;
            long ID = Convert.ToInt64(productSummaryList.SelectedID);
            IProduct  product = ProductController.GetProduct(ID);
            if(product != null)
            {
                lbName.Text = product.Name;
                //lbCode.Text = product.Code;
                lbContent.Text = product.Content;
                lbPrice.Text = product.Price.ToString();
                lbPriceSale.Text = product.PriceSale.ToString();
                //lbSeller.Text = product.Seller;
                lbSummary.Text = product.Summary;
                imgPreview.ImageUrl = String.Format("~/ImageView.aspx?id={0}&mdim=150",product.ImagePV);
                ibEditProduct.CommandArgument = product.ID.ToString();
                //imgThumnail.ImageUrl = String.Format("~/ImageView.aspx?id={0}&mdim=80", product.ImageTN);
            }
        }
        public string SelectedID
        {
            get
            {
                return (string)ViewState["productViewDetailID"];
            }
            set { ViewState["productViewDetailID"] = value; }
        }
        public void Doshow(object sender, EventArgs e)
        {
            this.Visible = true;
        }
        public void DoHidden(object sender, EventArgs e)
        {
            this.Visible = false;
        }

        protected void btnReturnListSummary_Click(object sender, EventArgs e)
        {
            if (EventReturnProductListSummary != null)
            {
                EventReturnProductListSummary(sender, e);
            }
        }
        protected void ibEditProduct_Click(object sender, ImageClickEventArgs e)
        {
            SelectedID = ibEditProduct.CommandArgument; 
            if (EventImageEdit != null)
            {
                EventImageEdit(this, e);
            }
        }
    }
}